home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / c_news / 09 / hgraph2 / h_demo2.c < prev    next >
C/C++ Source or Header  |  1988-07-14  |  7KB  |  244 lines

  1. #include <h_graph2.c>
  2.  
  3. main()
  4. {
  5.    extern char fore[],back[],lgrey[],wrhatch[];
  6.    extern int stndl[],glass[],check[],xmark[],hand[];
  7.    char alphabet[3590];
  8.    char far *shape;
  9.    int status,buttons,i,j,k;
  10.    status=h_isherc();
  11.    switch(status)
  12.    {
  13.       case -1:
  14.          printf("** Sorry, a color card is installed **\n");
  15.          exit();
  16.          break;
  17.       case 1:
  18.          printf("** Sorry, adapter is not Hercules compatible **\n");
  19.          exit();
  20.          break;
  21.       default:
  22.          printf("** Hercules compatible adapter installed **\n");
  23.     }
  24.     status=m_init(&buttons);
  25.     if(status!=-1)
  26.     {
  27.        printf("** Mouse driver not installed **\n");
  28.        buttons=0;
  29.     }
  30.     else
  31.     {
  32.        printf("** Mouse driver detected with %d buttons **\n",buttons);
  33.     }
  34.     printf("\n\n\n** Press a key to begin the box demo **\n");
  35.     printf("** Continue pressing until demo is over **\n");
  36.     getch();
  37.     status=h_init(99);
  38.     if(status==7)
  39.     {
  40.        printf("** Sorry, can't initialize graphics **\n");
  41.        exit();
  42.     }
  43.    h_setpmode(H_PSET);
  44.    h_moveto(0,0);
  45.    h_box(719,347,fore);
  46.    getch();
  47.    h_box(719,347,lgrey);
  48.    getch();
  49.    h_clrw(back);
  50.    h_moveto(0,0);
  51.    h_patterns();
  52.    getch();
  53.    h_clrw(fore);
  54.    getch();
  55.    h_clrw(back);
  56.    h_explode(fore);
  57.    h_explode(lgrey);
  58.    h_explode(back);
  59.    h_moveto(10,10);
  60.    status=h_loadfont("standard.fnt",alphabet);
  61.    if(status)
  62.    {
  63.       h_init(7);
  64.       printf("\n ***** ERROR - can not find standard.fnt file *****\n");
  65.    }
  66.    else
  67.    {
  68.       h_draws("This is STANDARD.FNT",alphabet);
  69.       status=h_loadfont("script.fnt",alphabet);
  70.       h_moveto(10,24);
  71.       if(status)
  72.       {
  73.          h_draws(" ***** ERROR - can not find script.fnt file *****",alphabet);
  74.       }
  75.       else
  76.       {
  77.          h_draws("This is SCRIPT.FNT",alphabet);
  78.       }
  79.       h_moveto(10,38);
  80.       status=h_loadfont("smallapl.fnt",alphabet);
  81.       if(status)
  82.       {
  83.          h_draws(" ***** ERROR - can not find smallapl.fnt file *****",alphabet);
  84.       }
  85.       else
  86.       {
  87.          h_draws("This is SMALLAPL.FNT",alphabet);
  88.       }
  89.       h_moveto(10,52);
  90.       status=h_loadfont("gothic.fnt",alphabet);
  91.       if(status)
  92.       {
  93.          h_draws(" ***** ERROR - can not find gothic.fnt file *****",alphabet);
  94.       }
  95.       else
  96.       {
  97.          h_draws("This is GOTHIC.FNT",alphabet);
  98.       }
  99.       h_moveto(10,66);
  100.       status=h_loadfont("compute.fnt",alphabet);
  101.       if(status)
  102.       {
  103.          h_draws(" ***** ERROR - can not find compute.fnt file *****",alphabet);
  104.       }
  105.       else
  106.       {
  107.          h_draws("This is COMPUTE.FNT",alphabet);
  108.       }
  109.       h_moveto(10,80);
  110.       status=h_loadfont("italic.fnt",alphabet);
  111.       if(status)
  112.       {
  113.          h_draws(" ***** ERROR - can not find italic.fnt file *****",alphabet);
  114.       }
  115.       else
  116.       {
  117.          h_draws("This is ITALIC.FNT",alphabet);
  118.       }
  119.       h_moveto(10,94);
  120.       status=h_loadfont("apl.fnt",alphabet);
  121.       if(status)
  122.       {
  123.          h_draws(" ***** ERROR - can not find apl.fnt file *****",alphabet);
  124.       }
  125.       else
  126.       {
  127.          h_draws("This is APL.FNT",alphabet);
  128.       }
  129.       h_moveto(10,320);
  130.       status=h_loadfont("sideways.fnt",alphabet);
  131.       if(status)
  132.       {
  133.          h_draws(" ***** ERROR - can not find sideways.fnt file *****",alphabet);
  134.       }
  135.       else
  136.       {
  137.          h_draws("This is SIDEWAYS.FNT",alphabet);
  138.       }
  139.       getch();
  140.       h_loadfont("standard.fnt",alphabet);
  141.       h_clrw(wrhatch);
  142.       h_moveto(10,10);
  143.       h_draws("This is H_PSET put mode",alphabet);
  144.       getch();
  145.       h_clrw(wrhatch);
  146.       h_moveto(10,10);
  147.       h_setpmode(H_OR);
  148.       h_draws("This is H_OR put mode",alphabet);
  149.       getch();
  150.       h_clrw(wrhatch);
  151.       h_moveto(10,10);
  152.       h_setpmode(H_XOR);
  153.       h_draws("This is H_XOR put mode",alphabet);
  154.       getch();
  155.       h_moveto(10,10);
  156.       h_draws("This is H_XOR put mode",alphabet);
  157.       getch();
  158.       h_clrw(back);
  159.       h_moveto(10,10);
  160.       h_draws("This is how to make grey text using the H_AND mode of H_BOXFILL",alphabet);
  161.       h_moveto(10,10);
  162.       h_setpmode(H_AND);
  163.       getch();
  164.       h_boxfill(577,24,lgrey);
  165.       getch();
  166.       h_moveto(0,0);
  167.       h_setpmode(H_PSET);
  168.       h_clrw(back);
  169.       h_box(639,199,fore);
  170.       if(buttons)
  171.       {
  172.          m_cursor(ON);
  173.          h_moveto(10,220);
  174.          h_draws("After m_init, the mouse is limited to this area",alphabet);
  175.          h_moveto(10,234);
  176.          h_draws("You must use m_limit to allow full screen movement",alphabet);
  177.          getch();
  178.          m_limit(0,0,719,347);
  179.          getch();
  180.          m_cursor(OFF);
  181.          h_clrw(back);
  182.          h_moveto(10,10);
  183.          h_draws("m_limit can also constrict mouse movement",alphabet);
  184.          h_moveto(360,174);
  185.          h_box(620,320,fore);
  186.          m_limit(360,174,620,320);
  187.          m_cursor(ON);
  188.          getch();
  189.          m_cursor(OFF);
  190.          h_clrw(back);
  191.          h_moveto(10,10);
  192.          m_limit(0,0,719,347);
  193.          h_draws("m_move can be used to force the mouse cursor to any screen position",alphabet);
  194.          m_cursor(ON);
  195.          for(k=0;k<5;k++)
  196.          {
  197.             for(i=0,j=0;i<698;i+=2,j++)
  198.             {
  199.                m_move(i,j);
  200.             }
  201.          }
  202.          m_move(360,174);
  203.          getch();
  204.          m_cursor(OFF);
  205.          h_clrw(back);
  206.          h_moveto(10,10);
  207.          h_draws("m_shape creates different mouse cursor shapes",alphabet);
  208.          h_moveto(10,24);
  209.          h_draws("You will need a function to turn a pointer into a segment & offset",alphabet);
  210.          h_moveto(10,38);
  211.          h_draws("Look for ones called FP_SEG & FP_OFF",alphabet);
  212.          m_cursor(ON);
  213.          for(i=0;i<5;i++)
  214.          {
  215.             getch();
  216.             switch(i)
  217.             {
  218.                case 0:
  219.                   shape=hand;
  220.                   break;
  221.                case 1:
  222.                   shape=glass;
  223.                   break;
  224.                case 2:
  225.                   shape=check;
  226.                   break;
  227.                case 3:
  228.                   shape=xmark;
  229.                   break;
  230.                case 4:
  231.                   shape=stndl;
  232.                   break;
  233.             }
  234.             m_shape(FP_SEG(shape),FP_OFF(shape));
  235.          }
  236.          getch();
  237.          m_cursor(OFF);
  238.       }
  239.    }
  240.    if(buttons==0) getch();
  241.    h_init(7);
  242.    printf("\n ** End of DEMO **\n");
  243. }
  244.